package cn.xmkeshe.dao;

import cn.xmkeshe.model.Logger;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ILoggerDao {

  //  统计数量
  @Select("select COUNT(id) from logger")
  public Integer getAllCount();

  @Insert("insert into logger(ip,url,httpMethod,classMethod,requestParams,result,timeCost,description,type,createDate)values(#{ip},#{url},#{httpMethod},#{classMethod},#{requestParams},#{result},#{timeCost},#{description},#{type},#{createDate})")
  public boolean insert(Logger log);

  @Select("select * from logger where type = '管理员' LIMIT #{currentPage},#{lineSize}")
  public List<Logger> admin(@Param("currentPage") int currentPage, @Param("lineSize") int lineSize);

  @Select("select * from logger where type = '用户' LIMIT #{currentPage},#{lineSize}")
  public List<Logger> customer(@Param("currentPage") int currentPage, @Param("lineSize") int lineSize);

  @Select("select * from logger where type = '系统' LIMIT #{currentPage},#{lineSize}")
  public List<Logger> system(@Param("currentPage") int currentPage, @Param("lineSize") int lineSize);

  @Select("select * from logger where type = '司机' LIMIT #{currentPage},#{lineSize}")
  public List<Logger> driver(@Param("currentPage") int currentPage, @Param("lineSize") int lineSize);

  @Delete("delete from logger where id = #{id}")
  public boolean delete(int id);

  @Select("select * from logger where createDate like #{createDate} LIMIT #{currentPage},#{lineSize}")
  public List<Logger> findByCreateDate(@Param("currentPage") int currentPage, @Param("lineSize") int lineSize, @Param("createDate") String createDate);
}
